package jea.machine.transverseprofileviewer;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.LineBorder;

import jea.machine.gui.MainGui;
import models.ModelLayoutTable;

public class FrameLayoutTable extends JInternalFrame implements ActionListener
{
	private static final long serialVersionUID = 1L;

	private JPanel panelTable, panelSynthese;
	private JTable tableLayout;
	private JScrollPane scrollpaneTable;
	private ModelLayoutTable modelTL;
	
	public FrameLayoutTable(ModelLayoutTable mlt)
	{
		this.modelTL = mlt;
    	this.setLayout(new BorderLayout());
		this.setClosable(true);
		this.setIconifiable(true);
		this.setMaximizable(true);
		this.setResizable(true);
		this.setTitle(modelTL.getTitle());
		this.setBorder(new LineBorder(Color.DARK_GRAY, 2));
		this.setLocation(100, 100);
		this.setSize(new Dimension(900, 600));
		this.setVisible(true);
		initPanels();
	}
	
	private void initPanels()
	{
	   panelSynthese = new JPanel(new BorderLayout());
	   JLabel labelSynthese = new JLabel("<html>"+modelTL.getSynthese()+"</html>");
	   //labelSynthese.setPreferredSize(new Dimension(1,1));
	   panelSynthese.add(labelSynthese);
	   
	   panelTable = new JPanel(new BorderLayout());
	   //  String titres[] = new String[] {"COL1", "COL2", "COL3"};
       //  Object data[][] = new Object[][] { {"1", "2", "3", "4"}, {"5", "6", "7", "8"}, {"9", "10", "11", "12"}, {"13", "14", "15", "16"}};
       //  ModelLayoutTable monModel = new ModelLayoutTable(titres, data);
	  tableLayout = new JTable(modelTL);
	  scrollpaneTable = new JScrollPane(tableLayout);
	  panelTable.add(scrollpaneTable);
	  this.add(panelSynthese, BorderLayout.NORTH);
	  this.add(panelTable, BorderLayout.CENTER);
	  MainGui.desktop.add(this);
	  //System.out.println("DONE");
	}
	
	@Override
	public void actionPerformed(ActionEvent arg0)
	{
		// TODO Auto-generated method stub	
	}

}
